import { useState, useEffect } from 'react'
import KeepAlive from 'react-activation'
import './index.less'

/**
 * Home page
 */
const HomePage = () => {

  const [data, setData] = useState('')

  useEffect(() => {
    fetcher()
  }, [])

  const fetcher = async () => {
    await new Promise((resolve, reject) => {
      setTimeout(() => {
        resolve('data')
      }, 6000)
    }).then((res: any) => {
      setData(res)
    })
  }

  return <>
    <div className='home-page'>
      homepage
    </div>
  </>
}

const KeepAliveHomePage = () => {
  return <KeepAlive name='home' key='home'>
    <HomePage />
  </KeepAlive>
}

export default KeepAliveHomePage
